package com.oms.app.food.service.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.oms.app.food.dao.IFoodDAO;
import com.oms.app.food.model.Food;
import com.oms.app.food.service.IFoodService;
import com.oms.app.sequence.service.impl.SequenceManager;
import com.oms.core.service.impl.GeneralService;
import com.oms.util.IDCreator;

/**
 * @author Loong_Mit
 * @date Sep 1, 2012 7:03:38 PM
 */

public class FoodServiceImpl extends GeneralService<Food, String> implements IFoodService {

	@Override
	public List<Food> getFoodList(HttpServletRequest request) {
		return ((IFoodDAO) dao).getShopList(request);
	}

	@Override
	public boolean addFood(Food foodForm) {
		foodForm.setId(new Integer(SequenceManager.nextID("food")));
		foodForm.setCode(IDCreator.newId());
		foodForm.setSequence(Integer.valueOf(((IFoodDAO) dao).getFoodSequence(foodForm.getShopid())));
		foodForm.setStatus(Integer.valueOf(1));
		return ((IFoodDAO) dao).addFood(foodForm);
	}

	@Override
	public boolean deleteFood(String PK) {
		return ((IFoodDAO) dao).deleteFood(PK);
	}

	@Override
	public boolean updateFood(Food foodForm) {
		return ((IFoodDAO) dao).updateFood(foodForm);
	}
}